columnview: Simplify column constructors
authorMatthias Clasen <mclasen@redhat.com>
Fri, 25 Sep 2020 17:53:42 +0000 (13:53 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 25 Sep 2020 17:57:10 +0000 (13:57 -0400)
Drop gtk_column_view_column_new_with_factory and
just make gtk_column_view_column_new accept a
nullable factory. This follows what we've been
doing elsewhere.

Update all callers.

docs/reference/gtk/gtk4-sections.txt
gtk/gtkcolumnviewcolumn.c
gtk/gtkcolumnviewcolumn.h
tests/testcolumnview.c
tests/testlistdnd.c

index a5246c6dae82bd9c5af359760a03e33978201b30..6e70be79be9a78a0ed071b9516050a9b64933960 100644 (file)
@@ -555,7 +555,6 @@ gtk_column_view_get_type
 <TITLE>GtkColumnViewColumn</TITLE>
 GtkColumnViewColumn
 gtk_column_view_column_new
-gtk_column_view_column_new_with_factory
 gtk_column_view_column_get_column_view
 gtk_column_view_column_set_factory
 gtk_column_view_column_get_factory
index c1e7c1831720edcfa8d8e85a322f2b604059e9fb..478cc5fe3f30f6e08e9e32f1d58955ffe79ad63a 100644 (file)
@@ -357,25 +357,7 @@ gtk_column_view_column_init (GtkColumnViewColumn *self)
 /**
  * gtk_column_view_column_new:
  * @title: (nullable): Title to use for this column
- *
- * Creates a new #GtkColumnViewColumn.
- *
- * You most likely want to call gtk_column_view_add_column() next.
- *
- * Returns: a new #GtkColumnViewColumn
- **/
-GtkColumnViewColumn *
-gtk_column_view_column_new (const char *title)
-{
-  return g_object_new (GTK_TYPE_COLUMN_VIEW_COLUMN,
-                       "title", title,
-                       NULL);
-}
-
-/**
- * gtk_column_view_column_new_with_factory:
- * @title: (nullable): Title to use for this column
- * @factory: (transfer full): The factory to populate items with
+ * @factory: (transfer full) (nullable): The factory to populate items with
  *
  * Creates a new #GtkColumnViewColumn that uses the given @factory for
  * mapping items to widgets.
@@ -385,15 +367,15 @@ gtk_column_view_column_new (const char *title)
  * The function takes ownership of the
  * argument, so you can write code like
  * ```
- *   column = gtk_column_view_column_new_with_factory (_("Name"),
+ *   column = gtk_column_view_column_new (_("Name"),
  *     gtk_builder_list_item_factory_new_from_resource ("/name.ui"));
  * ```
  *
  * Returns: a new #GtkColumnViewColumn using the given @factory
  **/
 GtkColumnViewColumn *
-gtk_column_view_column_new_with_factory (const char         *title,
-                                         GtkListItemFactory *factory)
+gtk_column_view_column_new (const char         *title,
+                            GtkListItemFactory *factory)
 {
   GtkColumnViewColumn *result;
 
@@ -404,7 +386,7 @@ gtk_column_view_column_new_with_factory (const char         *title,
                          "title", title,
                          NULL);
 
-  g_object_unref (factory);
+  g_clear_object (&factory);
 
   return result;
 }
index 6125f16f76ac44a7db4df98e3bbb5984e7ef801b..5baf5b972c15e368bfb624270758ac1be66a6590 100644 (file)
@@ -47,9 +47,7 @@ GDK_AVAILABLE_IN_ALL
 GType                   gtk_column_view_column_get_type                 (void) G_GNUC_CONST;
 
 GDK_AVAILABLE_IN_ALL
-GtkColumnViewColumn *   gtk_column_view_column_new                      (const char             *title);
-GDK_AVAILABLE_IN_ALL
-GtkColumnViewColumn *   gtk_column_view_column_new_with_factory         (const char             *title,
+GtkColumnViewColumn *   gtk_column_view_column_new                      (const char             *title,
                                                                          GtkListItemFactory     *factory);
 
 GDK_AVAILABLE_IN_ALL
index aa7e76939321ff4cec3f7c3352e1ac44705957ba..04f09f1ee54d2a9fef3835cb644e7d5613059a4b 100644 (file)
@@ -662,7 +662,7 @@ add_extra_columns (GtkColumnView   *view,
   for (i = 0; i < G_N_ELEMENTS(extra_columns); i++)
     {
       bytes = g_bytes_new_static (extra_columns[i].factory_xml, strlen (extra_columns[i].factory_xml));
-      column = gtk_column_view_column_new_with_factory (extra_columns[i].title,
+      column = gtk_column_view_column_new (extra_columns[i].title,
           gtk_builder_list_item_factory_new_from_bytes (scope, bytes));
       g_bytes_unref (bytes);
       sorter = GTK_SORTER (gtk_custom_sorter_new (compare_file_attribute, (gpointer) extra_columns[i].attribute, NULL));
index 803ff2164d2ff069498437ce8c6feeb0616f3381..60c943715d88d0901584ca52588287fc7730f571 100644 (file)
@@ -388,7 +388,7 @@ main (int argc, char *argv[])
       g_signal_connect (factory, "unbind", G_CALLBACK (unbind_item), NULL);
 
       title = g_strdup_printf ("Column %u", i);
-      column = gtk_column_view_column_new_with_factory (title, factory);
+      column = gtk_column_view_column_new (title, factory);
       gtk_column_view_append_column (GTK_COLUMN_VIEW (cv), column);
       g_object_unref (column);
       g_free (title);